package com.thinkgem.jeesite.modules.test.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletRequest;
/**
 * 将请求的request放到ThreadLocal中管理
 */
public class RequestHolder {
    private static final Logger logger = LoggerFactory.getLogger(RequestHolder.class);
    private static ThreadLocal<HttpServletRequest> requestHolder = new ThreadLocal<HttpServletRequest>();
    public static HttpServletRequest getRequest(){

        return requestHolder.get();
    }
    public static void setRequest(HttpServletRequest request){
        logger.info("当前的存入了Request对象：{}", request);
        requestHolder.set(request);
    }
    public static void removeRequest(){
        requestHolder.remove();
    }
}
